<?php

class Application_Model_DbTable_Zonas extends Zend_Db_Table_Abstract
{

    protected $_name = 'zonas';

	public function getZonasByIdPais($idPais) {
		$select  = $this->_db->select()
			->from($this->_name, array('key' => 'id_zona','value' => 'nombre'))
			->where('id_pais = ?',$idPais);

		$result = $this->getAdapter()->fetchAll($select);

		return $result;
	}
		
	public function getZonas() {
		$select  = $this->_db->select()
			->from($this->_name)
			->joinLeft('paises','paises.id_pais = zonas.id_pais',array('nombrePais' => 'nombre'));
// print_r($select->__toString());die();
		$result = $this->getAdapter()->fetchAll($select);

		return $result;
	}
	
	public function getZonasFromId($idZona) {
		$select  = $this->_db->select()
			->from($this->_name)->where($this->_name.'.id_zona = ?', $idZona);
		
		$result = $this->getAdapter()->fetchAll($select);

		return $result;
	}
}

